package qz_rpt

class RepairRecordController {

    def commonDataService
    def dynamicQueryService
    def index(Integer max) {
        def cellList = org.kdx.DataUtils.getCellList()
        def pageSizeList = org.kdx.DataUtils.getPageSizeList()

        [totalCount: 5, pageSize: 20, pageCurrent: 1, orderField: 'id', orderDirection: 'asc', pageSizeList: pageSizeList, cellList: cellList]
    }

    def repairRecord(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10,20,50,100]

        params.SYS_QUERY_NAME = 'repairRecord'
        def repairRecord = dynamicQueryService.queryForList(params)
        def tableHeadList = []
        if (repairRecord.size() > 0) {
            tableHeadList = repairRecord[0].keySet()
        }
        params.SYS_QUERY_NAME = 'repairRecordCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

        params.SYS_QUERY_NAME = 'repairRecordWoId'
        def repairRecordWoId = dynamicQueryService.queryForList(params)

        params.SYS_QUERY_NAME = 'repairRecordPart'
        def repairRecordPart = dynamicQueryService.queryForList(params)

        params.SYS_QUERY_NAME = 'repairRecordState'
        def repairRecordState = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'repairRecordSum'
        def repairRecordSum = dynamicQueryService.queryForList(params)

        [pageSize  : pageSize, pageSizeList: pageSizeList, startno: params.startno ?: '', endno: params.endno ?: '',
         totalCount: totalCount, tableHeadList: tableHeadList, repairRecord: repairRecord,
         startTime: params.startTime ?: '', endTime: params.endTime ?: '',
         repairRecordPart:repairRecordPart,part:params.part?:'',
         repairRecordWoId:repairRecordWoId,woId:params.woId?:'',user:params.user?:'',
         repairRecordState:repairRecordState,state:params.state?:'',
         repairRecordSum:repairRecordSum
        ]
    }

    def repairRecordStep(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10,20,50,100]

        params.SYS_QUERY_NAME = 'repairRecordStep'
        def repairRecordStep = dynamicQueryService.queryForList(params)
        def tableHeadList = []
        if (repairRecordStep.size() > 0) {
            tableHeadList = repairRecordStep[0].keySet()
        }
        params.SYS_QUERY_NAME = 'repairRecordStepCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

        params.SYS_QUERY_NAME = 'repairRecordStepSum'
        def repairRecordStepSum = dynamicQueryService.queryForList(params)

        [pageSize  : pageSize, pageSizeList: pageSizeList, startno: params.startno ?: '', endno: params.endno ?: '',
         totalCount: totalCount, tableHeadList: tableHeadList, repairRecordStep: repairRecordStep,
                woId1:params.woId1?:'',repairRecordStepSum:repairRecordStepSum,user:params.user?:''
        ]
    }
}
